<?php
namespace app\mobile\controller;

use app\model\Theme; 

class Joinshop extends Base
{
    public function Joinshop()
    {
global $_G, $_P;
$fans = $this->checkuser();
$themeid = intval($_P['themeid']);
if($themeid < 0){
	return_msg('管理后台地址不正确');
}
$system=$_G['system'];
$theme = Theme::getThemeById($themeid);
$config = 	Theme::getConfig($themeid);
$workerid = $_P['workerid'];
$recordid = $_P['recordid'];

if(empty($theme['id'])){
	return_msg('管理后台地址不正确');
}
$op = !empty($_P['op']) ? $_P['op'] : 'display';

	$sharedata = array(
	    'themeid'=>$themeid,
	    'fopenid'=>$_G['openid'],
	    'fromuid'=>$_G['member']['uid'],
	    'workerid'=>$workerid,
	    'flag'=>1,
	    'recordid'=>$recordid
	);

	$shareurl =   $_G['siteroot'].createMobileUrl('index',$sharedata);


if ($op=='save') {
	if (empty($_P['mobile']) || empty($_P['name'])){
		return_msg('企业名称与电话必须填写');
	}
	$data = array (
			'uniacid' => $_G['mpid'],
			'name' => $_P['name'],
			'mobile' => $_P['mobile'],
			'address' => $_P['address'],
			'content'=>($_P['content']),
			'state' => 3,
	);
	db_insert ( t_shangjia, $data );
	$shangjiaid = $insertid;

	message ( '报名成功！', $shareurl, 'success' );
}

$return_clicent = get_defined_vars();
return view('/duoshangjia/joinshop', $return_clicent);
}
}